/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package poo.biblioteca.vistas.lectores;

import biblioteca.entidades.TipoLector;
import java.awt.event.ActionListener;
import java.util.ArrayList;

/**
 *
 * @author apo
 */
public class PnlLector extends javax.swing.JPanel {

    /**
     * Creates new form PnlLector
     */
    public PnlLector() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        txtIdLector = new javax.swing.JTextField();
        txtNombres = new javax.swing.JTextField();
        txtApellidos = new javax.swing.JTextField();
        cmbTipoLector = new javax.swing.JComboBox();
        txtCodigoAlumno = new javax.swing.JTextField();
        txtDNI = new javax.swing.JTextField();
        lblIdLector = new javax.swing.JLabel();
        lblNombres = new javax.swing.JLabel();
        lblApellidos = new javax.swing.JLabel();
        lblTipoLector = new javax.swing.JLabel();
        lblCodigoAlumno = new javax.swing.JLabel();
        lblDNI = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();
        lblEMail = new javax.swing.JLabel();
        lblTelefono = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();

        setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Lector"));

        txtIdLector.setEnabled(false);

        lblIdLector.setText("Id Lector:");

        lblNombres.setText("Nombres:");

        lblApellidos.setText("Apellidos:");

        lblTipoLector.setText("Tipo de Lector:");

        lblCodigoAlumno.setText("Código de alumno:");

        lblDNI.setText("DNI:");

        lblEMail.setText("EMail:");

        lblTelefono.setText("Teléfono:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblCodigoAlumno)
                    .addComponent(lblDNI)
                    .addComponent(lblEMail)
                    .addComponent(lblTelefono)
                    .addComponent(lblApellidos)
                    .addComponent(lblNombres)
                    .addComponent(lblTipoLector)
                    .addComponent(lblIdLector))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtApellidos)
                    .addComponent(txtDNI)
                    .addComponent(txtEmail)
                    .addComponent(txtNombres)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtIdLector, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cmbTipoLector, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtCodigoAlumno, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 96, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdLector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdLector))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombres))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblApellidos))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblTipoLector)
                    .addComponent(cmbTipoLector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtCodigoAlumno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblCodigoAlumno))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtDNI, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblDNI))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEMail)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTelefono))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cmbTipoLector;
    private javax.swing.JLabel lblApellidos;
    private javax.swing.JLabel lblCodigoAlumno;
    private javax.swing.JLabel lblDNI;
    private javax.swing.JLabel lblEMail;
    private javax.swing.JLabel lblIdLector;
    private javax.swing.JLabel lblNombres;
    private javax.swing.JLabel lblTelefono;
    private javax.swing.JLabel lblTipoLector;
    private javax.swing.JTextField txtApellidos;
    private javax.swing.JTextField txtCodigoAlumno;
    private javax.swing.JTextField txtDNI;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtIdLector;
    private javax.swing.JTextField txtNombres;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables

    //IdLector
    public void setIdLector(String idLector) {
        txtIdLector.setText(idLector);
    }

    public String getIdLector() {
        return txtIdLector.getText();
    }
    //Nombres

    public void setNombres(String nombres) {
        txtNombres.setText(nombres);
    }

    public String getNombres() {
        return txtNombres.getText();
    }
    //Apellidos

    public void setApellidos(String apellidos) {
        txtApellidos.setText(apellidos);
    }

    public String getApellidos() {
        return txtApellidos.getText();
    }
    //CodigoAlumno

    public void setCodigoAlumno(String codigoAlumno) {
        txtCodigoAlumno.setText(codigoAlumno);
    }

    public String getCodigoAlumno() {
        return txtCodigoAlumno.getText();
    }
    //TipoLector

    public void setTiposDeLectores(ArrayList<TipoLector> tiposDeLectores) {
        for (TipoLector tipo : tiposDeLectores) {
            cmbTipoLector.addItem(tipo);
        }
    }

    public TipoLector getTipoLector() {
        return (TipoLector) cmbTipoLector.getSelectedItem();
    }
    //Dni
    public void setDni (String dni) {
        txtDNI.setText(dni);
    }
    public String getDni () {
        return txtDNI.getText();
    }
    //Email
    public void setEmail (String email) {
        txtEmail.setText(email);
    }
    public String getEmail () {
        return txtEmail.getText();
    }
    //Telefono
    public void setTelefono (String telefono) {
        txtTelefono.setText(telefono);
    }
    public String getTelefono () {
        return txtTelefono.getText();
    }

    public void limpiarCampos() {
        txtNombres.setText("");
        txtApellidos.setText("");
        txtCodigoAlumno.setText("");
        cmbTipoLector.setSelectedIndex(0);
        txtDNI.setText("");
        txtEmail.setText("");
        txtTelefono.setText("");
        txtNombres.requestFocusInWindow();
    }
    
    public void habilitarCampoCódigoAlumno(boolean habilitar) {
        if(!habilitar)
            txtCodigoAlumno.setText("");
        txtCodigoAlumno.setEnabled(habilitar);
    }
    
    public void cmbTipoLectorAddActionListener (ActionListener al) {
        cmbTipoLector.addActionListener(al);
    }
}
